<template>
  <div class="title">
    <div>
      <span class="title_name">{{title}}</span>
      <span v-if="subTitle" class="sub_title_name"> - {{subTitle}}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "",
      subTitle: "",
      routeName: "",
      selectTitle: false,
      selectTitleIdx: 0
    };
  },
  created() {
    this.setTitle();
  },
  watch: {
    $route() {
      this.setTitle();
    }
  },
  methods: {
    setTitle: function() {
      this.title = this.routeName = this.$route.meta.title;
      this.subTitle = "";
    },
    setSubTitle: function(data) {
      this.subTitle = data.title;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "../assets/css/common.scss";

.title {
  .select_title {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(0, -50%);
    z-index: 1;
    width: 308px;
    line-height: normal;
    font-size: 0;
    span {
      width: 0;
      height: 36px;
      display: inline-block;
      text-align: center;
      vertical-align: middle;
      font-size: 26px;
      transition: all $transitionTime;
      transform-origin: 50% 0%;
      opacity: 0;
      &.last {
        text-indent: -22px;
      }
      &.select {
        width: 200px;
        opacity: 1;
      }
    }
    &:after {
      content: "";
      position: absolute;
      left: 50%;
      transform: translate(-50%, 0);
      bottom: 0;
      width: 90%;
      height: 2px;
      background-color: $mtColor;
    }
    li {
      &.select {
        background-color: $mtColor;
        color: #fff;
      }
      transition: all $transitionTime;
      display: inline-block;
      vertical-align: middle;
      border: 2px solid $mtColor;
      width: 36px;
      height: 36px;
      text-align: center;
      line-height: 32px;
      border-radius: 50%;
      color: $mtColor;
      font-size: 14px;
    }
  }
  .title_name {
    line-height: $titleHeight;
    position: relative;
    font-size: 26px;
    &::before {
      content: "";
      position: absolute;
      top: 0;
      left: -15px;
      width: 5px;
      height: 100%;
      background-color: $mtColor;
    }
  }
  .sub_title_name {
    line-height: $titleHeight;
    position: relative;
    font-size: 26px;
  }
}
</style>
